dofile (getScriptPath() .. "\\..\\processor\\processor.lua")
dofile (getScriptPath() .. "\\..\\processor\\notify.lua")

dofile (getScriptPath() .. "\\..\\lib\\actions.lua")
dofile (getScriptPath() .. "\\..\\lib\\lib.lua")

script_name = string.gsub(string.gsub(debug.getinfo(1).short_src, "%.[^%.]*$", ""), "^.*[\\/]", "")

fix_profit = {fix_rate = 2}

processor:AddHandler("OnRun", function(t)
	processor:stop(0)  
end)

processor:AddInit(function()
	client_code = lib:GetUser()
    if not client_code then return true end
	script_id = client_code .. "#" .. script_name
	
	processor:SetTimer(2000)
	
	--message(lib:toline(getParamEx2(lib:GetInstrument("FXGD").class_code, "FXGD", "buyprofit")))
end)
	
processor:AddTimer(function(t)
	if not lib:isConnected() then return true end
end)
	
processor:AddTimer(function(t)
	local a = lib:GetAssets()
	local pl, rc = lib:GetPL()
	
	if rc and a and rc > fix_profit.fix_rate then
		fix_profit:Exit()
		processor:stop(0)       
	end
end)

function fix_profit:Exit()
	processor:notify("FIX PROFIT " .. client_code)
	
	actions:Exit()
end


